package com.example.wangzh.mytest;

import com.example.wangzh.mytest.base.BaseActivity;
import com.example.wangzh.mytest.databinding.ActivityWalkeralgorithmTestBinding;
import com.example.wangzh.mytest.part.walker_algorithm.TreePositioner;
import com.example.wangzh.mytest.part.walker_algorithm.TreePositioner.Node;

public class WalkerAlgorithmTestActivity extends BaseActivity<ActivityWalkeralgorithmTestBinding> {
    @Override
    protected void initView() {
        Node root = new Node("root");
        double screenWidth = getResources().getDisplayMetrics().widthPixels;
        root.setXCoord(screenWidth/2);
        Node a = new Node("a");
        Node b = new Node("b");
        Node c = new Node("c");
        Node d = new Node("d");
        Node e = new Node("e");
        Node f = new Node("f");
        Node g = new Node("g");
        Node h = new Node("h");
        Node i = new Node("i");
        Node j = new Node("j");
        Node k = new Node("k");
        Node l = new Node("l");
        Node m = new Node("m");
        Node n = new Node("n");
        root.setFirstChild(e);

        e.setParent(root);
        e.setRightSibling(f);
        e.setFirstChild(a);

        a.setParent(e);
        a.setRightSibling(d);

        d.setParent(e);
        d.setLeftSibling(a);
        d.setFirstChild(b);

        b.setParent(d);
        b.setRightSibling(c);

        c.setParent(d);
        c.setLeftSibling(b);

        f.setParent(root);
        f.setLeftSibling(e);
        f.setRightSibling(n);

        n.setParent(root);
        n.setLeftSibling(f);
        n.setFirstChild(g);

        g.setParent(n);
        g.setRightSibling(m);

        m.setParent(n);
        m.setLeftSibling(g);
        m.setFirstChild(h);

        h.setParent(m);
        h.setRightSibling(i);

        i.setParent(m);
        i.setLeftSibling(h);
        i.setRightSibling(j);

        j.setParent(m);
        j.setLeftSibling(i);
        j.setRightSibling(k);

        k.setParent(m);
        k.setLeftSibling(j);
        k.setRightSibling(l);

        l.setParent(m);
        l.setLeftSibling(k);

        TreePositioner positioner = new TreePositioner();
        positioner.positionTree(root);
        mBinding.walkerTreeView.setTree(root);
    }
}
